import { defineStore } from 'pinia';

const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.loop = true

export const useIconMusicStore = defineStore('iconMusic', {
	state: () => {
		return { 
			flag:false,
			src:'http://rjinbysql.hn-bkt.clouddn.com/static/music/萧亚轩 - 遗失的心跳.mp3'
		};
	},
	actions:{
		play(){
			this.flag = !this.flag
			if(!innerAudioContext.src){
				innerAudioContext.src = this.src
			}
			
			if(this.flag){
				innerAudioContext.play()
			}else{
				innerAudioContext.pause()
			}
			
		}
	}
});